<?php 
class accordion extends CI_Controls{

	public $headers;
	public $contents;


	function __construct(){
		parent::__construct();
		$this->headers=array();
		$this->contents=array();
	}

	function drawContent(){
		if(!empty($this->headers) && !empty($this->contents)){
			//div principal

			$accordion=new div();
			$accordion->atributos=$this->atributos;
			//ul para las cabeceras

			$nhead=count($this->headers);
			for($i=0;$i<$nhead;++$i){
				$h=new h(3);
				$h->value=$this->headers[$i];
				$accordion->addControl($h);
				$cont=new div();
				$cont->att('id',$this->att('id').'-'.($i+1));
				$cont->value=$this->contents[$i];
				$accordion->addControl($cont);
				}
			$this->accordionScript();
			return $accordion ;
		}
	}

	private function accordionScript(){

		ob_start();
		?>
			<script>
			 $(function() {
			        $( "#<?php echo $this->att('id')?>" ).accordion();
			    });
			</script>
​
		<?php
			
		 $this->CI->dynamic_assets->add_code_js(ob_get_clean());
			
	}
}